// import Cart from '@/views/cart'
// import Category from '@/views/category'
// import SubCategory from '@/views/category/SubCategory'
// import Detail from '@/views/detail'
// import Home from '@/views/home'
// import Login from '@/views/login'
// import Mine from '@/views/mine'
// import Confirm from '@/views/confirm'
// import Navbar from '@/components/navbar'
// import Tabbar from '@/components/tabbar'

const Cart = () => import('@/views/cart')
const Category = () => import('@/views/category')
const SubCategory = () => import('@/views/category/SubCategory')
const Detail = () => import('@/views/detail')
const Home = () => import('@/views/home')
const Login = () => import('@/views/login')
const Mine = () => import('@/views/mine')
const Confirm = () => import('@/views/confirm')
const Navbar = () => import('@/components/navbar')
const Tabbar = () => import('@/components/tabbar')

const routes = [
  {
    path: '/',
    redirect: '/home', // 重定向
  },
  {
    path: '/home',
    name: 'Home',
    components: {
      default: Home,
      footer: Tabbar,
    },
    meta: { // 路由元信息，可保存自定义的数据，供开发过程中进行调用
      title: '首页',
      icon: '&#xe601;',
      inTabbar: true, // 是否包含在 tabbar 中
      canotBack: true, // 不需要在 navbar 中添加返回按钮
    },
  },
  {
    path: '/category',
    name: 'Category',
    components: {
      header: Navbar,
      default: Category,
      footer: Tabbar,
    },
    children: [ // 子路由配置（嵌套路由配置）
      {
        path: 'sub', // 注意，没有以 '/' 开头，它的完整路径为：/category/sub
        name: 'SubCategory',
        component: SubCategory,
        meta: {
          title: '子分类',
        },
      },
    ],
    meta: {
      title: '分类',
      icon: '&#xe603;',
      inTabbar: true,
      canotBack: true,
    },
  },
  {
    path: '/cart',
    name: 'Cart',
    components: {
      header: Navbar,
      default: Cart,
      footer: Tabbar,
    },
    meta: {
      title: '购物车',
      icon: '&#xe600;',
      inTabbar: true,
      canotBack: true,
      hasBadge: true,
    },
  },
  {
    path: '/mine',
    name: 'Mine',
    components: {
      header: Navbar,
      default: Mine,
      footer: Tabbar,
    },
    meta: {
      title: '我的',
      icon: '&#xe602;',
      inTabbar: true,
      canotBack: true,
    },
  },
  {
    path: '/detail/:id',
    name: 'Detail',
    components: {
      header: Navbar,
      default: Detail,
    },
    meta: {
      title: '商品详情',
    },
  },
  {
    path: '/login',
    name: 'Login',
    components: {
      header: Navbar,
      default: Login,
    },
    meta: {
      title: '登录',
    },
  },
  {
    path: '/confirm',
    components: {
      header: Navbar,
      default: Confirm,
    },
    meta: {
      title: '确认订单',
    },
  },
]

export default routes
